package entity;

import org.hibernate.annotations.*;
import org.hibernate.annotations.Cache;

import javax.persistence.*;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.List;

/**
 * Created by xuweijie on 17-5-8.
 */
@Entity
@Table(name = "sys_provience")
//@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class SysProvience implements Serializable{
    private int id;
    private SysCountry country;
    private String name;
    private String code;
    private List<SysCitys> citylist;

    @Id
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @ManyToOne(cascade = {CascadeType.REFRESH}, fetch = FetchType.EAGER)
    @JoinColumn(name = "countryid", referencedColumnName = "id")
    public SysCountry getCountry() {
        return country;
    }

    public void setCountry(SysCountry country) {
        this.country = country;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    @OneToMany(mappedBy = "province", cascade = {CascadeType.REFRESH}, fetch = FetchType.EAGER)
//    @Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
    public List<SysCitys> getCitylist() {
        return citylist;
    }

    public void setCitylist(List<SysCitys> citylist) {
        this.citylist = citylist;
    }
}



